package demo2;

/**
 * @Author liangzai
 * @Description:
 */
class Student implements Comparable<Student>{
    public String name;
    public int age;

    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public int compareTo(Student student){
        return this.age-student.age;
    }
}

public class Test {
    public static void main(String[] args) {
        Student[] students = new Student[3];
        students[0]=new Student("liuzhi",19);
        students[1]=new Student("huxiangyu",18);
        students[2]=new Student("zhanglujie",20);

        int ret=students[0].compareTo(students[1]);
        System.out.println(ret);
        //Arrays.sort(students);
    }
}
